var express = require('express');
var BackstageOrder = express.Router();
var dbcomm = require('./util/dbcomm');
var moment = require('moment');
var bodyparser = require('body-parser');
var now = moment().format('YYYY年MM月DD日') ;//日期

BackstageOrder.use(bodyparser.urlencoded({extended:false}));

//显示订单
BackstageOrder.get('/showOrder',function(req,res){
    var query = req.query;
    console.log(query);
    var star = parseInt(query.page - 1) * parseInt(query.rows);//query.page是当前页数,query.rows是每一页显示多少行数据
    var end = parseInt(query.rows);
    var sql = "select * from sys_order limit ?,?";
    var myjson = {};
    dbcomm.query(sql,[star,end],function (err,data){
        myjson.rows = data;//当前是多少行
        dbcomm.query("select * from sys_order",function (err,data){
            if (err) throw err;
            // console.log(data);
            myjson.total = data.length;//总共有多少行
            res.send(myjson);
        });
    });
});

module.exports = BackstageOrder;